
$(document).ready(function(){
	$("#toregister").click(function () {
		if((password = $("#password").val()) != $("#password2").val()) {
			alert("两次密码不一致");
			return;
		}

		$.ajax({
			url:"register",
			data:{"realname":$("#realname").val(),"userid":$("#userid").val(),"username":$("#username").val(),"password":password},
			type:"post",
			dataType:"json",
			success: function (data) {
				switch(data.status) {
					case 1:
						alert(data.mag);
						location.href = "login";
						break;
					case 0:
						alert(data.mag);
						break;
				}
			}
		})
	});
});